package com.my.controller;


import com.my.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin("*")
@RequestMapping("/business")
public class BusinessController {

    BusinessService businessService;

    @Autowired
    public void setBusinessService(BusinessService businessService) {
        this.businessService = businessService;
    }

    @RequestMapping("/loginByPassword")
    public String loginByPassword(String username, String password) {
        return this.businessService.loginByPassword(username, password);
    }

    @RequestMapping("/loginByFace")
    public String loginByFace(String MD5) {
        return this.businessService.loginByFace(MD5);
    }


    @RequestMapping("/loginByPhone")
    public String loginByPhone(String phone, String code) {
        return this.businessService.loginByPhone(phone, code);
    }

    @RequestMapping("/loginByEmail")
    public String loginByEmail(String email, String code) {
        return this.businessService.loginByEmail(email, code);
    }


    @RequestMapping("/sendPhoneMessage")
    public String sendPhoneMessage(String phone) {
        return this.businessService.sendPhoneMessage(phone);
    }


    @RequestMapping("/sendEmailMessage")
    public String sendEmailMessage(String email) {
        return this.businessService.sendEmailMessage(email);
    }

    @RequestMapping("/register")
    public String register(String username, String password, String shopName, String face, String phone, String email) {
        return this.businessService.register(username, password, shopName, face, phone, email);
    }

    @RequestMapping("/author")
    public String getAuthor(HttpServletRequest req) {
        return this.businessService.getAuthor(req);
    }
}
